import { axios } from "@/utils/request";
import { baseUrl } from "@/services/baseUrl";

//项目里程碑接口
export function pageProgressMilestone(data) {
  let { page, pageSize, proId } = data;
  return axios({
    url:
      baseUrl +
      `/portcommon/scheduleMilestoneProject/getProListByQXPage?pageNo=${page}&pageSize=${pageSize}&order=desc&sort=createTime`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: {
      proId,
    },
  });
}
//项目里程碑-详情
export function progressMilestoneDetail(data) {
  let { proCode } = data;
  return axios({
    url:
      baseUrl +
      `/portcommon/scheduleMilestoneProject/getDetailByProCode?proCode=${proCode}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: {},
  });
}
//项目里程碑-编辑
export function progressMilestoneSaveOrUpdate(data) {
  return axios({
    url: baseUrl + `/portcommon/scheduleMilestoneProject/saveOrUpdate`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//项目里程碑-名称下拉框
export function getMajorList(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getMajorList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//wbs-树形数据
export function getWbsTreeData(data) {
  let { orgCode } = data;
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/getTreeData?orgCode=${orgCode}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: {},
  });
}

//wbs-分页数据
export function pageWbs(data) {
  let { page, pageSize } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleWbs/getListData?pageNo=${page}&pageSize=${pageSize}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//wbs-工程下拉框
export function getWorksSelect(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/getWorksSelect`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//wbs-新增/编辑
export function wbsSaveOrUpdate(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/saveOrUpdateData`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//wbs-详情
export function wbsDetail(data) {
  let { uuid } = data;
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/getDetail?id=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
  });
}
//wbs-删除
export function wbsDelete(data) {
  let { uuid } = data;
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/deleteData?id=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
  });
}

//wbs-下载模版
export function downloadWbsTemplate(data = {}) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/downloadTemplate`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
  });
}

//wbs-批量导出
export function exportWbsExcel(data) {
  let { orgCode } = data;
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/exportData?orgCode=${orgCode}`,
    method: "POST",
    apiType: "file",
    responseType: "arraybuffer",
  });
}

//wbs-批量导入
export function importWbsExcel(file) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbs/importExcel`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: file,
  });
}

//工序报验-单位工程下拉框
export function getUnitWorksSelect(params) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbsProcedure/getUnitWorksSelect`,
    method: "GET",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    params,
  });
}

//工序报验-完成数量/总数量
export function getStatisticsNumber(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbsProcedure/getStatisticsNumber`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//工序报验-今日报验数量/审批数量
export function getTodayNumebr(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbsProcedure/getStatisticsToday`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//工序报验-卡片列表
export function getUnitWordList(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbsProcedure/getUnitWordList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//工序报验-基本信息
export function getUnitWordDetail(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbsProcedure/getUnitWordDetail`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//工序报验-工程信息树
export function getGCXXTreeData(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleWbsProcedure/getGCXXTreeData`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//工序报验-工程信息列表
export function getGCXXList(data) {
  let { page, pageSize } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleWbsProcedure/getGCXXList?pageNo=${page}&pageSize=${pageSize}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//港区管理-分页数据
export function pagePortArea() {
  return axios({
    url: baseUrl + `/probusiness/lygPortAreaRegionMarking/queryRegionList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: {},
  });
}

//【总计划管控】

//外层列表页
export function getPlanControlPage(data) {
  let { page, pageSize } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfig/getProjectScheduleList?pageNo=${page}&pageSize=${pageSize}&order=desc&sort=createTime`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//正式-树
export function getTreeList(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getTreeList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//草稿-树
export function getTreeListDraft(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigDraft/getTreeList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//草稿-懒加载子级
export function getTreeListDraftChildren(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigDraft/getListByParentId`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//历史-树
export function getTreeListHistory(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigHistory/getTreeList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-获取版本
export function getPlanControlVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/getVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
export function getPlanControlVersionNew(params) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/getLastVersion`,
    method: "GET",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    params,
  });
}

// 总计划管控 - 下载模版
export function downloadPlanControlTemplate(params) {
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfigDraft/downloadTemplateByType`,
    method: "GET",
    params,
    apiType: "file",
    responseType: "arraybuffer",
  });
}
//总计划管控-导入
export function importPlanControl(file, params, apiName = "importData") {
  let { proCode, orgCode, versionId = "" } = params;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfigDraft/${apiName}?proCode=${proCode}&orgCode=${orgCode}&versionId=${versionId}`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: file,
    // onUploadProgress: (progressEvent) => {
    //   //   let persent = ((progressEvent.loaded / progressEvent.total) * 100) | 0; //上传进度百分比
    //   let persent = Math.round(
    //     (progressEvent.loaded * 100) / progressEvent.total
    //   );
    //   callback(persent);
    // },
  });
}

//总计划管控-导入验证
export function importVerify(file, data) {
  console.log("data", data);
  let { proCode, orgCode, versionId = "" } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfigDraft/importVerify?proCode=${proCode}&orgCode=${orgCode}&versionId=${versionId}`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: file,
  });
}

// 根据父级id获取数据列表-正式-表格
export function getListByParentIdTable(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getTableListByParentId`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 根据父级id获取数据列表-正式-表格【新】
export function getTableData(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getTableData`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

////////////////////////////////

// 根据父级id获取数据列表-草稿-表格【新】
export function getTableDataDraft(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigDraft/getTableData`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 根据父级id获取数据列表-归档-表格【新】
export function getTableDataHistory(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigHistory/getTableData`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

////////////////////////

// 根据父级id获取数据列表-草稿
export function getListByParentIdDraft(data) {
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfigDraft/getTableListByParentId`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 根据父级id获取数据列表-历史
export function getListByParentIdHistory(data) {
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfigHistory/getTableListByParentId`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 根据父级id获取数据列表-进度跟踪
export function getProgressTrackingList(data) {
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfig/getTableListAndFillByParentId`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//进度项配置-填报详情
export function getFillReportDetail(params) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getFillDetail`,
    method: "GET",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    params,
  });
}

//进度项配置-详情-正式
export function getConfigDetail(data) {
  let { proCode, uuid } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfig/getDetail?proCode=${proCode}&id=${uuid}`,
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    method: "POST",
  });
}
//进度项配置-详情-草稿
export function getConfigDetailDraft(data) {
  let { proCode, uuid } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfigDraft/getDetail?proCode=${proCode}&id=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
  });
}
//进度项配置-详情-历史
export function getConfigDetailHistory(data) {
  let { proCode, uuid } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfigHistory/getDetail?proCode=${proCode}&id=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
  });
}

//进度项配置-填报
export function saveFillReport(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/scheduleFill`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 总计划管控 - 编辑
export function savePlanControl(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigDraft/saveAllData`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//
export function savePlanData(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfigDraft/saveOrUpdate`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-发布版本
export function publishVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/publishVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//总计划管控-发布子版本
export function publishChildVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/publishChildVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-新建版本
export function createVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/createVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//总计划管控-新建子版本
export function createChildVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/createChildVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 总计划管控 - 版本对比-列表
export function versionList(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/getList`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//总计划管控-审批
export function approvePlanControl(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/approveVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//投资计划-审批
export function approveInvestmentPlanControl(data) {
  return axios({
    url: baseUrl + `/probusiness/investmentVersion/approveVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-批量导出
export function exportPlanControl(data, apiName = "exportDataByType") {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/${apiName}`,
    method: "POST",
    apiType: "file",
    responseType: "arraybuffer",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-提交版本
export function submitVersion(data) {
  let { uuid, proCode } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemVersion/submitVersion?uuid=${uuid}&proCode=${proCode}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: {},
  });
}

//总计划管理-更新调整状态
export function updateVserionStatus(data) {
  return service({
    url: baseUrl + `/probusiness/scheduleItemVersion/updateVserion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//版本删除
export function deleteVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/deleteVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-任务删除
export function deletePlanControlTask(data) {
  let { uuid } = data;
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfigDraft/deleteData?uuid=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//总计划管控-任务删除验证
export function deleteVerify(data) {
  let { uuid } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/scheduleItemConfigDraft/deleteVerify?uuid=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//网络图-子计划-正式
export function getChildNetworkDiagram(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getChildNetworkDiagram`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//网络图-子计划-草稿
export function getChildNetworkDiagramDraft(data) {
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfigDraft/getChildNetworkDiagram`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//网络图-子计划-历史
export function getChildNetworkDiagramHistory(data) {
  return axios({
    url:
      baseUrl + `/probusiness/scheduleItemConfigHistory/getChildNetworkDiagram`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

// 检查版本
export function checkVersion(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemVersion/checkVersion`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}
//填报验证
export function fillVerify(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/fillVerify`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

export function getNetworkDiagram(data) {
  return axios({
    url: baseUrl + `/probusiness/scheduleItemConfig/getNetworkDiagram`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//删除计划投资数据
export function deletePlan(data) {
  let { uuid } = data;
  return axios({
    url: baseUrl + `/probusiness/investmentPlan/deletePlan?uuid=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//删除计划合同数据
export function deletePlanContract(data) {
  let { uuid } = data;
  return axios({
    url:
      baseUrl + `/probusiness/investmentPlan/deletePlanContract?uuid=${uuid}`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//新增编辑计划投资数据
export function addAndEditPlan(data) {
  return axios({
    url: baseUrl + `/probusiness/investmentPlan/addAndEditPlan`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//新增编辑投资合同数据
export function addAndEditContract(data) {
  return axios({
    url: baseUrl + `/probusiness/investmentPlan/addAndEditContract`,
    method: "POST",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
}

//导出
export function exportPlan(data) {
  let { versionId } = data;
  return axios({
    url:
      baseUrl + `/probusiness/investmentPlan/exportPlan?versionId=${versionId}`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
  });
}

//下载计划表
export function downloadPlan(data) {
  let { versionId, proCode, month } = data;
  return axios({
    url:
      baseUrl +
      `/probusiness/investmentPlan/shop/downloadPlan?versionId=${versionId}&proCode=${proCode}&month=${month ||
        ""}`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
  });
}
